#ifndef AVALON_SERVICEPROTOCOLSERVERCHANNEL_HPP
#define AVALON_SERVICEPROTOCOLSERVERCHANNEL_HPP
#include "Avalon/IO/ConnectionState.hpp"
#include "Avalon/Threading/AsyncTaskQueue.hpp"
#include "Avalon/Threading/Async.hpp"
#include "Avalon/Services/ServiceProtocol.hpp"

namespace Avalon {
namespace Services {

  /*! \class ServiceProtocolServerChannel
      \brief Mixin-class for a Channel used by the ServiceProtocolServer.
   */
  class ServiceProtocolServerChannel {
    public:

      //! Constructs a ServiceProtocolServerChannel.
      ServiceProtocolServerChannel();

      ~ServiceProtocolServerChannel();

      //! Sends a Message.
      /*!
        \param message The Message to send.
      */
      void SendMessage(const Message& message);

      //! Returns the Channel's ConnectionState.
      IO::ConnectionState& GetConnectionState();

      //! Returns the tasks queued for this Channel.
      Threading::AsyncTaskQueue& GetTaskQueue();

      //! Returns the result of the last task that completed.
      Threading::Async<void>& GetLastTaskResult();

      //! Returns the ServiceProtocol.
      ServiceProtocol& GetServiceProtocol();

    private:
      IO::ConnectionState m_connectionState;
      Threading::AsyncTaskQueue m_taskQueue;
      Threading::Async<void> m_lastTaskResult;
      ServiceProtocol m_serviceProtocol;
  };
}
}

#endif // AVALON_SERVICEPROTOCOLSERVERCHANNEL_HPP
